package jman.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

public class Vote_User2Dao {
	public boolean add(int vote_id,int user_id,String status){
		boolean flag=false;
		Dao d=new Dao();
		d.start();
		String sql="insert into vote_user2 (vote_id,user_id,status) values ("+vote_id+","+user_id+",'"+status+"')";
		flag=d.add(sql);
		d.close();
		return flag;
	}
	public boolean update(int id,int vote_Id){
		boolean flag=false;
		Dao d=new Dao();
		d.start();
		String sql="update vote_user2 set status='是' where vote_id="+vote_Id+" and user_id="+id;
		flag=d.update(sql);
		d.close();
		return flag;
	}
	public boolean isFinish(int vote_Id) throws SQLException{
		boolean flag=true;
		Dao d=new Dao();
		d.start();
		String sql="select * from vote_user2 where vote_id="+vote_Id+" and status='否'";
		ResultSet rs=d.read(sql);
		while(rs.next()){
			flag=false;
		}
		d.close();
		return flag;
	}
	public boolean isVote(int user_Id,int vote_Id) throws SQLException{
		boolean flag=false;
		Dao d=new Dao();
		d.start();
		String sql="select * from vote_user2 where user_id="+user_Id+" and vote_id="+vote_Id+" and status='否'";
		ResultSet rs=d.read(sql);
		while(rs.next()){
			flag=true;
		}
		d.close();
		return flag;
	}
}
